@extends('layouts.userctl')
@section('content')
<style>
	.formpage {
		width: 800px;
		height: auto;
		margin: 10px auto;
	}
	.layui-form-label {
		width: 150px;
	}

	.layui-input-block {
		margin-left: 150px;
	}

	.needed {
		color: #e62828;
	}

	.layui-form-item .layui-input-inline {
		width: 152px;
	}

	.mainpeo {
		flex: 1;
		margin-right: 10px;
	}

	.lastright {
		margin-right: 0 !important;
	}
	.uploading1{
		display:none;
	}
	.uploading2{
		display:none;
	}
	.delrow{
		font-size: 34px; color: #F0280F;
	}
	.delrow:hover{
		background-color: #EEEEEE;
	}
</style>
<div class="formpage">
	<form class="layui-form" action="{{route('admin.department.adddepartment')}}" method="post"
		onkeypress="return event.keyCode != 13;">
		{{csrf_field()}}
		<div class="layui-form-item">
			<label class="layui-form-label">人员姓名	<span class="needed"></span></label>
			<div class="layui-input-block">
				<input type="text" lay-verify="required" name="name" placeholder="请输入人员名称" class="layui-input" value="">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">政府角色</label>
			<div class="layui-input-block" style="display: flex;flex-direction: row;">
				<div class="layui-input-inline" style="flex: 1;">
					<select name="province" lay-filter="provincediv" id="provincediv" lay-search disabled="disabled">
						<option value="">请选择省份</option>
						@foreach($provinces as $p)
						<option value="{{$p['id']}}">{{$p['name']}}</option>
						@endforeach
					</select>
				</div>
				<div class="layui-input-inline" style="flex: 1;">
					<select name="city" lay-filter="citydiv" id="citydiv" lay-search disabled="disabled">
						<option value="">请选择市</option>
						@foreach($citys as $p)
						<option value="{{$p['id']}}">{{$p['name']}}</option>
						@endforeach
					</select>
				</div>
				<div class="layui-input-inline" style="flex: 1;">
					<select name="district" lay-filter="districtdiv" id="districtdiv" lay-search disabled="disabled">
						<option value="">请选择县/区</option>
						@foreach($districts as $p)
						<option value="{{$p['id']}}">{{$p['name']}}</option>
						@endforeach
					</select>
				</div>
				<div class="layui-input-inline" style="flex: 1.5;margin-right: 0;">
					<select name="street" lay-filter="streetdiv" id="streetdiv" lay-search 
						@if ($role=='street_admin') 
						disabled="disabled" 
						@endif
					>
						<option value="">请选择镇/街道</option>
						@foreach($streets as $p)
						<option value="{{$p['id']}}">{{$p['name']}}</option>
						@endforeach
					</select>
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">	<span class="needed"></span></label>
			<div class="layui-input-block">
				<div class="layui-input-inline" style="flex: 1;width: 100%;">
					<select name="role"  lay-filter="role" id="role" lay-search lay-verify="required">
						<option value="">请选择角色</option>
						<option value="emergency">应急管理局</option>
						<option value="policea">公安局</option>
						<option value="enforcement">城市管理和综合行政执法局</option>
						<option value="supervise">市场监管局</option>
						<option value="rescue">消防救援大队</option>
						<option value="sports">教育和体育局</option>
						<option value="miit">工业和信息化局</option>
						<option value="business">商务局</option>
						<option value="travel">文化和旅游局</option>
						<option value="hygiene">卫生健康局</option>
					</select>
				</div>
			</div>
		</div>		
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button>
				<a href="{{ url()->previous() }}" class="layui-btn layui-btn-primary">返 回</a>
			</div>
		</div>
	</form>
</div>
<script>
	layui.use('form', function() {
		var form = layui.form;
		var $ = layui.jquery
		  ,upload = layui.upload
		  ,element = layui.element
		  ,layer = layui.layer;
		var province_code = 370000,
			city_code = 371100,
			district_code = 371102,
			street_code
		$('#provincediv').val(province_code)
		$('#citydiv').val(city_code)
		$('#districtdiv').val(district_code)
		var role = '{{$role}}'
		if (role != 'district_admin' && role != 'admin') {
			
			$('#role').val(role)
			$('#role').prop('disabled',true)
		}
		form.render(); 
		
		$('#backpage').click(function() {
			history.back(-1)
		})
		//监听提交
		form.on('submit(formDemo)', function(data) {
			var index = layer.load(0, { shade: false })
			$('form').find('input,select').removeAttr('disabled')
		})
	})
</script>

@endsection
